package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.mine.entity.OrderRefundCancelBean;
import com.beiing.tianshuai.tianshuai.mine.entity.OrderRefundStateDataBean;
import com.beiing.tianshuai.tianshuai.mine.model.OrderAfterSaleStateModel;
import com.beiing.tianshuai.tianshuai.mine.model.OrderAfterSaleStateModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.OrderAfterSaleStateViewImpl;

public class OrderAfterSaleStatePresenter implements OrderAfterSaleStatePresenterImpl,
        OrderAfterSaleStateModel.OrderAfterSaleStateDataResponseListener,
        OrderAfterSaleStateModel.OrderCancelRefundResponseListener{

    private OrderAfterSaleStateViewImpl mView;
    private OrderAfterSaleStateModelImpl mModel;

    public OrderAfterSaleStatePresenter(OrderAfterSaleStateViewImpl view) {
        mView = view;
        mModel = new OrderAfterSaleStateModel(this,this);
    }

    /**
     * 请求退货状态
     * @param mOrdersId 订单id
     */
    @Override
    public void getOrderAfterSaleState(String mOrdersId) {
        mView.showProgress();
        mModel.getOrderAfterSaleState(mOrdersId);
    }

    /**
     * 执行取消售后操作
     * @param mOrdersId 订单id
     */
    @Override
    public void getOrderCancelRefundCode(String mOrdersId) {
        mView.showProgress();
        mModel.getOrderCancelRefundCode(mOrdersId);
    }

    @Override
    public void onGetDetailSuccess(OrderRefundStateDataBean bean) {
        //请求数据成功返回
        mView.hideProgress();
        mView.getOrderAfterSaleStateSuccess(bean);
    }

    @Override
    public void onGetDetailError(Throwable throwable) {
        //失败
        mView.getOrderAfterSaleStateError(throwable);
    }

    @Override
    public void onGetCancelDetailSuccess(OrderRefundCancelBean bean) {
        //请求数据成功返回
        mView.hideProgress();
        mView.getOrderCancelRefundSuccess(bean);
    }

    @Override
    public void onGetCancelDetailError(Throwable throwable) {
        mView.getOrderCancelRefundError(throwable);

    }
}
